package com.luo.consume.consume;

import com.luo.common.base.BaseConsumer;
import com.luo.common.order.OrderCreateEvent;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

/**
 * 订单消息事件消费.
 * <p>
 * topic：需要和生产者的topic一致
 * selectorExpression：指的就是tag，默认为“*”，不设置的话会监听所有消息
 * consumerGroup：属性是必须指定的，内容可以随意
 *
 * @author Luo
 * @version 3.8
 * @date 2021-08-11 9:44
 */
@Slf4j
@Component
@RocketMQMessageListener(topic = "${rocketmq.order.topic}", selectorExpression = "OrderCreateEvent", consumerGroup = "${rocketmq.order.consumerGroup}")
public class OrderCreateConsumer extends BaseConsumer<OrderCreateEvent> implements RocketMQListener<OrderCreateEvent> {


    /**
     * 消息处理.
     *
     * @param msg msg
     */
    @Override
    public void onMessage(final OrderCreateEvent msg) {
        super.onMessage(msg);
    }

    @Override
    protected String getKey(final OrderCreateEvent msg) {
        return null;
    }

    @Override
    protected void doProcess(final OrderCreateEvent msg) {
        log.info("监听到消息：{}", msg);
    }

}
